// pages/sponsorManage/sponsorManage.js
var $=require('../util/commit.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    selectIndex:0,
    psnData:[{
      id:0,
      url:'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
      name:'橙风破浪',
     
    }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }, {
        id: 1,
        url: 'https://app.xingxue.vip/image1_1/group-buying_icon21.png',
        name: '橙风破浪',
      }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that=this;
    that.loadData();
  },
  loadData:function(e){
      let that=this;
      $.POST({
        url:'caSSL',
        data:{

        }
      },function(e){
        that.setData({
          psnData:e.data.data,
          selectIndex: e.data.sid
        })
      },function(e){})
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.loadData();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  // selectItem
  selectItem:function(e){
    let that =this;
    let index=e.currentTarget.dataset.index;
    that.setData({
      selectIndex:index,
    });
    $.POST({
      url:'caSDS',
      data:{
        sid:e.currentTarget.dataset.sid,
      }
    },function(e){
      wx.showToast({
        title: e.msg,
        icon:'none'
      })
    },function(e){})
  },
  // addSponsor
  addSponsor:function(e){
    $.openWin({
      url:'../sponsorManage/sponsorMDetail',
      data:{
        Type:'Add',
      }
    })
  },
  // ToEidtSponsor
  ToEidtSponsor:function(e){
    $.openWin({
      url: '../sponsorManage/sponsorMDetail',
      data:{
        Type:"Eidt",
        sid: e.currentTarget.dataset.sid,
      }
    })
  }
})